<link rel="stylesheet" href="${baseStaticUrl}/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="${baseStaticUrl}/plugins/ztree/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${baseStaticUrl}/plugins/ztree/js/jquery.ztree.excheck.js"></script>
<div class="col-sm-2 col-xs-2 ">
	<ul id="sysMenuTree" class="ztree"></ul>
</div>
<div class="col-sm-10 col-xs-10">
	<epoch:table id="sysUserTable" queryUrl="${basePath}/sys/user/findUserListAjax" rowId="id" showRefresh="true" onDelClick="onDelete"
                    onAddClick="addClick" queryParam="queryParamFunction" newBtn="true" delBtn="true" exportFileName="用户">
           <epoch:tr check="checkbox" titleTip="全选"></epoch:tr>
           <epoch:tr name="员工编号" formName="employee_number"><a href="javascript:void(0)" style="color:#3c8dbc" onclick="viewAddPage('~{row.id}')">~{value}</a></epoch:tr>
           <epoch:tr name="用户名" formName="account" width="150"/>
           <epoch:tr name="中文姓名" formName="user_name" width="150"/>
           <epoch:tr name="邮箱" formName="email"></epoch:tr>
           <epoch:tr name="联系方式" formName="phone_number"></epoch:tr>
           <epoch:tr name="所属公司" formName="company_name"></epoch:tr>
           <epoch:tr name="部门" formName="dept_name"></epoch:tr>
           <epoch:tr name="员工状态" formName="status" filterType="select"
                   filterData="${lisFun.dictForFilter('SYS_USER_STATUS')}"><span style="color:red;"><strong>~{value}</strong></span></epoch:tr>
           <epoch:tr name="操作" switchable="true">
               <button class="btn btn-danger btn-xs" onclick="delRows('~{row.id}');">
                	<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>删除
                </button>
            </epoch:tr>
     </epoch:table>
<script type="text/javascript">
var zTreeObj;
var setting = {
    check: {
        enable: false
    },
    data: {
        simpleData: {
            enable: true
        }
    },
    callback: {
        onClick: zTreeOnClick
    }
};

var zNodes = [{
    name: "组织结构树",
    id: "0",
    open: true,
    children:${treeNodeJson}
}];
$(function(){
    zTreeObj = $.fn.zTree.init($("#sysMenuTree"), setting, zNodes);
});
var parentId = "";
var parentName = "组织管理";
function zTreeOnClick(event, treeId, treeNode) {
    var opt = {
        url: "${basePath}/sys/user/findUserListAjax",
        silent: true,
        query: {
            parentId: treeNode.id,
            parentName: treeNode.name
        }
    };
    $("#sysUserTable").bootstrapTable("refresh", opt);
    parentId = treeNode.id;
    parentName = treeNode.name;
}

function delRows(id){
	CommonUtil.del(null, id, "${basePath}/sys/user/delete",null,function(){
         _tabs.showPage("list");
     });
}
function onDelete(rows){
	CommonUtil.del(rows, "id", "${basePath}/sys/user/delete", null, function (data) {
		 _tabs.showPage("list");
    });
}
function addClick(){
	_tabs.showPage("information",null,null,null);	
}
function viewAddPage(id) {
    if (isEmpty(parentId) || isEmpty(parentName)) {
        _tabs.showPage("information",null,'ID=' + id,null);
    }else if(id!=null){
        _tabs.showPage("information",null,'ID=' + id,null);
    }else {
        _tabs.showPage("information",null,'parentId=' + parentId + '&parentName=' + encodeURIComponent(parentName),null);
    }
}
</script>